package com.uls.web.controller.lh;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.uls.lh.domain.LhCarinfo;
import com.uls.lh.domain.LhCarrequest;
import com.uls.lh.service.ILhCarinfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uls.common.annotation.Log;
import com.uls.common.core.controller.BaseController;
import com.uls.common.core.domain.AjaxResult;
import com.uls.common.enums.BusinessType;
import com.uls.lh.domain.LhFeeStandard;
import com.uls.lh.service.ILhFeeStandardService;
import com.uls.common.utils.poi.ExcelUtil;
import com.uls.common.core.page.TableDataInfo;

/**
 * 费用标准设置（按天数计算）Controller
 * 
 * @author lh
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/lh/standard")
public class LhFeeStandardController extends BaseController
{
    @Autowired
    private ILhFeeStandardService lhFeeStandardService;
    @Autowired
    private ILhCarinfoService lhCarinfoService;
    /**
     * 查询费用标准设置（按天数计算）列表
     */
    @PreAuthorize("@ss.hasPermi('lh:standard:list')")
    @GetMapping("/list")
    public TableDataInfo list(LhFeeStandard lhFeeStandard)
    {
        startPage();
        List<LhFeeStandard> list = lhFeeStandardService.selectLhFeeStandardList(lhFeeStandard);
        for (LhFeeStandard lhFeeStandard1 : list) {
            Long carId = lhFeeStandard1.getCarId();
            LhCarinfo lhCarinfo = lhCarinfoService.selectLhCarinfoByCarId(carId);
            if (lhCarinfo != null) {
                lhFeeStandard1.setModel(lhCarinfo.getModel());
            }


    }
        return getDataTable(list);
    }
    /**
     * 导出费用标准设置（按天数计算）列表
     */
    @PreAuthorize("@ss.hasPermi('lh:standard:export')")
    @Log(title = "费用标准设置（按天数计算）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LhFeeStandard lhFeeStandard)
    {
        List<LhFeeStandard> list = lhFeeStandardService.selectLhFeeStandardList(lhFeeStandard);
        ExcelUtil<LhFeeStandard> util = new ExcelUtil<LhFeeStandard>(LhFeeStandard.class);
        util.exportExcel(response, list, "费用标准设置（按天数计算）数据");
    }

    /**
     * 获取费用标准设置（按天数计算）详细信息
     */
    @PreAuthorize("@ss.hasPermi('lh:standard:query')")
    @GetMapping(value = "/{feestandardId}")
    public AjaxResult getInfo(@PathVariable("feestandardId") Long feestandardId)
    {
        return success(lhFeeStandardService.selectLhFeeStandardByFeestandardId(feestandardId));
    }

    /**
     * 新增费用标准设置（按天数计算）
     */
    @PreAuthorize("@ss.hasPermi('lh:standard:add')")
    @Log(title = "费用标准设置（按天数计算）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LhFeeStandard lhFeeStandard)
    {
        return toAjax(lhFeeStandardService.insertLhFeeStandard(lhFeeStandard));
    }

    /**
     * 修改费用标准设置（按天数计算）
     */
    @PreAuthorize("@ss.hasPermi('lh:standard:edit')")
    @Log(title = "费用标准设置（按天数计算）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LhFeeStandard lhFeeStandard)
    {
        return toAjax(lhFeeStandardService.updateLhFeeStandard(lhFeeStandard));
    }

    /**
     * 删除费用标准设置（按天数计算）
     */
    @PreAuthorize("@ss.hasPermi('lh:standard:remove')")
    @Log(title = "费用标准设置（按天数计算）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feestandardIds}")
    public AjaxResult remove(@PathVariable Long[] feestandardIds)
    {
        return toAjax(lhFeeStandardService.deleteLhFeeStandardByFeestandardIds(feestandardIds));
    }




}
